import React from "react";
export interface TableConfigItem {
  label: string;
  prop: string;
  //是否能打开详情弹窗
  isOpenView?: boolean;
  //自定义渲染内容
  render?(data: any): string | object | React.JSX.Element | JSX.Element;
  //表格列宽
  width?: number | string;
  //自定义插槽
  slot?: string;
  //列固定
  fixed?: "left" | "right" | boolean;
  //子级表头
  children?: Array<TableConfigItem>;
}

export interface TableOperate {
  label: string;
  width: number;
  fixed: "right" | "left"; //默认固定到右侧
  operateList: OperateItem[]; //操作列按钮组
}

export interface OperateItem {
  text: string | ((data: Record<string, unknown>, index?: number) => string);
  icon: any | ((data: Record<string, unknown>, index?: number) => any);
  handle(data: Record<string, unknown>, index?: number): void;
}

//编辑表格配置项
export interface WriteTableConfigItem extends TableConfigItem {
  //编辑状态时渲染的组件
  component: string | object;
  //组件属性
  attrs?: object;
  change?<V>(val: V, rowData: Record<string, unknown>): void;
}
